﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using JasRibbonApplicatie.Classes;
using System.Linq;

namespace JasRibbonApplicatie
{
    /// <summary>
    /// Interaction logic for MateriaalPicker.xaml
    /// </summary>
    public partial class MateriaalPicker : UserControl
    {
        private List<TypeMateriaalMetToebehoren> materiaalTypes;
        public List<TypeMateriaalMetToebehoren> MateriaalTypes
        {
            get
            {
                return this.materiaalTypes;
            }
            set
            {
                materiaalTypes = value;
                if (materiaalTypes != null)
                {
                    materiaalSoorten = (from types in MateriaalTypes
                                        select types.Type).Distinct().ToArray();
                    SoortListBox.ItemsSource = materiaalSoorten;
                }
            }
        }
        public TypeMateriaalMetToebehoren selectedMateriaalType { get; private set; }
        private string[] materiaalSoorten;
        public MateriaalPicker()
        {
            this.InitializeComponent();
        }
        private void SoortListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (SoortListBox.SelectedItem != null)
            {
                TypeListbox.ItemsSource = MateriaalTypes.Where(m => m.Type == SoortListBox.SelectedItem.ToString()).ToList();
            }
        }
        private void TypeListbox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (TypeListbox.SelectedItem != null)
                selectedMateriaalType = TypeListbox.SelectedItem as TypeMateriaalMetToebehoren;
            else selectedMateriaalType = null;
        }


    }
}